#!/usr/bin/env bash
# ******************************************************
# Filename     : mysql8.0_install_docker.sh
# Last modified: 2022-12-14 12:18
# Version      :
# Author       : jack.zang
# Email        : jack_zang@126.com
# Description  :
# curl -sfL https://gitee.com/jack_zang/public-scripts/raw/master/shell/mysql/mysql5.7_install_docker.sh | MYSQL_PASS="xdb5vRs2" sh -s -
#
# ******************************************************

mkdir /data/mysql57/data -pv
cat > /data/mysql57/my.cnf <<EOF
[mysqld]
skip-host-cache
skip-name-resolve
datadir=/var/lib/mysql
socket=/var/run/mysqld/mysqld.sock
secure-file-priv=/var/lib/mysql-files
user=mysql

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

#log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
socket=/var/run/mysqld/mysqld.sock
EOF

docker run --name mysql57 -d --restart=always -p 3306:3306 \
      -v /data/mysql57/data:/var/lib/mysql \
      -v /data/mysql57/my.cnf:/etc/my.cnf \
      -e MYSQL_ROOT_PASSWORD=${MYSQL_PASS}  --privileged=true \
      mysql:5.7.40